// import { Button, Result } from 'antd';
import React, { useEffect, useState, useRef } from 'react';
import { useLocation, useModel } from 'umi';
import styles from './index.less';
import { confirmPostMessage } from '@/utils/utils';

const NoFoundPage = () => {
  const location = useLocation();
  const [iframeSrc, setSrc] = useState(urlPrefix);
  const { iframeRef, urlPrefix } = useModel('Global');

  useEffect(() => {
    const src = `${urlPrefix}#${location.pathname}${location.search}`;
    setSrc(src);
    confirmPostMessage({
      ref: iframeRef,
    });
  }, [location.pathname]);

  console.log('iframeSrc', iframeSrc)
  return (
    // <Result
    //   status="404"
    //   title="404"
    //   subTitle="Sorry, the page you visited does not exist."
    //   extra={[
    //     <Button key="back" type="primary" onClick={() => history.back()}>
    //       返回上一页
    //     </Button>,
    //     <Button key="home" type="primary" onClick={() => history.push('/')}>
    //       回到首页
    //     </Button>,
    //   ]}
    // />
    <div className={styles.iframe_wrapper}>
      <iframe
        ref={iframeRef}
        id="frameContent"
        src={iframeSrc}
        className={styles.iframe_content}
      ></iframe>
    </div>
  );
};
// 修复umi bug兼容404
// NoFoundPage.path = undefined;
export default NoFoundPage;
